package com.syni.mdd.yhd.common.all.service;

import com.syni.mdd.yhd.common.all.dao.jpa.BmsUserReceGroupMessageDao;
import com.syni.mdd.yhd.common.all.entity.BmsUserReceGroupMessage;
import com.syni.mdd.yhd.common.all.service.impl.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @className
 * @description TOO
 * @Author cfx
 * @DATE 2019/4/9 12:04
 * @VERSION 1.0
 **/
@Service
public class BmsUserReceGroupMessageService extends BaseService<BmsUserReceGroupMessage, Integer> {

    @Autowired
    BmsUserReceGroupMessageDao bmsUserReceGroupMessageDao;


    @Override
    public BmsUserReceGroupMessageDao getBaseDao() {
        return bmsUserReceGroupMessageDao;
    }

    public Map<Integer, Integer> countGroupMessageUserNum(Set<Integer> groupMessageIds) {
        Map<Integer,Integer> resultMap = new HashMap<>();
        List<Map<String,Object>> countMap = bmsUserReceGroupMessageDao.countGroupMessageSendUserNum(groupMessageIds);
        if(countMap != null && countMap.size() > 0){
            for(Map<String,Object> objectMap : countMap){
                resultMap.put(Integer.parseInt(objectMap.get("groupMessageId").toString()),Integer.parseInt(objectMap.get("num").toString()));
            }
        }
        return resultMap;
    }
}
